<template>
    <el-table :data="tableData" fit border size="mini" :height='height'>
        <el-table-column prop="customer" label="业主姓名" width="120"></el-table-column>
        <el-table-column prop="id" label="UID" width="100"></el-table-column>
        <!-- <el-table-column prop="nickName" label="呢称"></el-table-column> -->
        <el-table-column prop="phone" label="手机号" width="150"></el-table-column>
        <el-table-column prop="housesNumberIds" label="房屋" ></el-table-column>
        <el-table-column prop="label" label="标签"></el-table-column>
        <el-table-column prop="createTime" label="创建时间"  width="180" sortable></el-table-column>
        <el-table-column label="操作" width="120">
        <template slot-scope="scope">
            <el-button type="text" size="small" @click="editUser(scope.row)">编辑</el-button>
            <!-- <el-button type="text" size="small" @click="del(scope.row)">删除</el-button>   暂时不做 -->
        </template>
        </el-table-column>
    </el-table>
</template>
<script>
import { request } from "../../assets/request.js";
export default {
    data(){
        return{
            tableData: [],
            obj:{
                size:20,
                page:1,
            },
            height: window.innerHeight - 280
        }
    },
    created(){
        this.selectList(this.obj)
        this.$root.$on('operateList',(data)=>{ //点击搜索
            this.obj=data
            this.selectList(this.obj)
        })
        this.$root.$on('page',(data)=>{ //点击页码
            this.obj=data
            this.selectList(this.obj)
        })
        this.$root.$on('sizeChange',(data)=>{ //选折每页多少条数据
            this.obj=data
            this.selectList(this.obj)
        })
    },
    methods:{
        del(){ //删除用户
            let that=this
            // console.log(row.id)
            request.delAlert({
                name:'删除该用户',
                that,
                fn(obj){
                    that.$message(obj)
                }
            })
        },
        editUser(row){
            this.$root.$emit("editUser",row)
        },
        selectList(obj){
            //列表请求
            let url = "user";
            let that = this; //解决this指向问题
            request.ajaxGet({
                url,
                that,
                params: obj,
                fn(res) {
                    console.log(res)
                    that.tableData=res.list
                    that.$root.$emit("operate",res.total)
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
</style>
